package com.starblink.android.basic.ext

import com.scwang.smart.refresh.layout.SmartRefreshLayout

/**
 * just can load more
 */
fun SmartRefreshLayout.justLoadMore(loadMore: (() -> Unit)? = null) {
    setEnableRefresh(false)
    setEnableAutoLoadMore(true)
    setOnLoadMoreListener {
        loadMore?.invoke()
    }
    setEnableLoadMoreWhenContentNotFull(false)
    setEnableNestedScroll(false)
}

fun SmartRefreshLayout.autoLoadAndRefresh(refresh: (() -> Unit)? = null, loadMore: (() -> Unit)? = null) {
    setEnableRefresh(true)
    setOnRefreshListener {
        refresh?.invoke()
    }
    setEnableAutoLoadMore(true)
    setOnLoadMoreListener {
        loadMore?.invoke()
    }
}